package com.xblibo.xruth.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.xblibo.xruth.common.BaseEntity;

/**   
 * @Title: Role.java
 * @Package xb.core.mode.role
 * @Description: TODO(角色，用于项目权限控制)
 * @author libo  
 * @date Dec 28, 2010 12:34:10 PM
 * @version V1.0   
 */
@Entity
@Table(name="role")
public class Role extends BaseEntity{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/** 
	 * 权限名称
	 */
	@Column(name="name",length=25)
	private String name;
	
	/**
	 * 权限英文name
	 */
	@Column(name="short_name",length=25)
	private String shortName;
	
	/**
	 * 权限对应的功能
	 */
	@ManyToMany(targetEntity = Function.class,cascade=CascadeType.ALL,fetch = FetchType.EAGER) 
	@JoinTable(name = "role_function", joinColumns = { @JoinColumn(name = "role_id",nullable = false,updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "function_id", nullable = false,updatable = false) }) 
	private Set<Function> functions;
	
	/**
	 * 是否是默认的,0为false,1为ture
	 */
	@Column(name="is_defual")
	private Boolean isDefual;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public Set<Function> getFunctions() {
		return functions;
	}
	public void setFunctions(Set<Function> functions) {
		this.functions = functions;
	}
	public Boolean getIsDefual() {
		return isDefual;
	}
	public void setIsDefual(Boolean isDefual) {
		this.isDefual = isDefual;
	}
	public String getShortName() {
		return shortName;
	}
	public void setShortName(String shortName) {
		this.shortName = shortName;
	}
	
}
